package xl.com.model;

import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 店铺订单表
 *
 * @author 张治保
 * @since 2022-06-08
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@TableName("t_shop_order")
@NoArgsConstructor
public class OrderItem {
//	@Id
//	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	@Serial
	private static final long serialVersionUID = 1L;

	/**
	 * 店铺订单号
	 * {主订单号}-{序号}
	 */
	private String no;

	/**
	 * 店铺id
	 */
	private Long shopId;

	/**
	 * 订单号
	 */
	private String orderNo;
	private String productName;

	/**
	 * 店铺名称
	 */
	private String shopName;


	/**
	 * 店铺logo
	 */
	private String shopLogo;


	/**
	 * 店铺订单实际总额
	 */
	private Long totalAmount;

	/**
	 * 店铺订单实际运费总额
	 */
	private Long freightAmount;

	/**
	 * 店铺订单折扣总额
	 */
	private Long discountAmount;

	/**
	 * 店铺订单备注
	 */
	private String remark;
	private Integer num;
	private LocalDateTime updateTime;
	private Integer status;
	private Integer afsStatus;





	public Long payAmount() {
		long total = getTotalAmount();
		total = total < 0 ? 0 : total;
		long freight = getFreightAmount();
		freight = freight < 0 ? 0 : freight;
		long discount = getDiscountAmount();
		discount = discount < 0 ? 0 : discount;
		return total + freight - discount;
	}

	public Object getStatus() {
		return "发货吗";
	}

	public Integer getAfsStatus() {
		return 3;
	}


	/**
	 * 店铺订单额外信息
	 */
	@Getter
	@Setter
	@ToString
	@Accessors(chain = true)
	public static class Extra implements Serializable {
		/**
		 * 初始化的空对象
		 */
		public static final Extra EMPTY = new Extra();

		/**
		 * 发货时间
		 */
		private LocalDateTime deliverTime;

		/**
		 * 收货时间
		 */
		private LocalDateTime receiveTime;


	}

}
